import { IAddArticleParam, IAddCommentParam, IAddReply, IGoodSaveParam, IRequestArticleParam } from '../interface/Article'
import * as request from './request'

export async function publishArticle(body: IAddArticleParam) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/add')
    return data
  } catch (e) {
    return (e)
  }
}

export async function getArticles(body: IRequestArticleParam) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/get')
    return data
  } catch (e) {
    return (e)
  }
}

export async function setGood(body: IGoodSaveParam) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/good')
    return data
  } catch (e) {
    return (e)
  }
}

export async function setSave(body: IGoodSaveParam) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/save')
    return data
  } catch (e) {
    return (e)
  }
}

export async function getDetailArticle(body: { articleId: string }) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/getDetail')
    return data
  } catch (e) {
    return (e)
  }
}

export async function deleteHandle(body: IGoodSaveParam) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/remove')
    return data
  } catch (e) {
    return (e)
  }
}


export async function addComment(body: IAddCommentParam) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/comment')
    return data
  } catch (e) {
    return (e)
  }
}

export async function addReply(body: IAddReply) {
  try {
    const data = await request.post(JSON.stringify(body), '/api/web/article/reply')
    return data
  } catch (e) {
    return (e)
  }
}